/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "ipc_object_stub.h"
#include <map>
#include <functional>

namespace OHOS {
class MockIPCObjectStub : public IPCObjectStub {
public:
    MockIPCObjectStub(const std::u16string& descriptor) : IPCObjectStub(descriptor) {}
    ~MockIPCObjectStub() = default;
    int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
    int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;

};


// 定义一个函数注册器类
class FunctionRegistry {
public:
    // 获取单例实例
    static FunctionRegistry& Instance();

    // 注册函数
    void RegisterFunction(int index, std::function<int(MessageParcel &)> func);

    // 调用函数
    int CallFunction(int index, MessageParcel &reply);

private:
    // 私有构造函数以实现单例模式
    FunctionRegistry() = default;

    // 存储函数的映射
    std::map<int, std::function<int(MessageParcel &)>> functionMap;
};



}